var SearchForm = function () {
  var template = /* html */ `
    <div class="search-form" v-loading.fullscreen.lock="loading">
      <el-form inline label-width="auto">
        <el-form-item label="系统订单编号">
          <el-input v-model="search.orderNo" class="search-input"></el-input>
        </el-form-item>
        <el-form-item label="订单编号">
          <el-input v-model="search.companyOrderNo" class="search-input"></el-input>
        </el-form-item>
        <el-form-item label="工厂型号">
          <el-input v-model="search.productNo" class="search-input"></el-input>
        </el-form-item>
        <el-form-item label="客户型号">
          <el-input v-model="search.custVersionNo" class="search-input"></el-input>
        </el-form-item>
        <el-form-item label="客户订单号">
          <el-input v-model="search.custOrderNo" class="search-input"></el-input>
        </el-form-item>
        <el-form-item label="部门">
          <el-select filterable clearable v-model="search.deptId" class="search-input">
            <el-option v-for="dept in deptList" :key="dept.id" :value="dept.id" :label="dept.name"></el-option>
          </el-select>
        </el-form-item>
      </el-form>
    </div>
  `;

  return {
    props: {
      search: {
        type: Object,
        required: true
      },
      dropdownOption: {
        type: Object,
        default: function () {
          return {};
        }
      }
    },

    data: function () {
      return {
        deptList: []
      };
    },

    created: function () {
      this.setDeptList();
    },

    methods: {
      setDeptList: function () {
        var dropdownOption = this.dropdownOption;
        var deptList = dropdownOption.deptList;
        if (deptList !== undefined) {
          this.deptList = deptList;
          return;
        }

        this.loading = true;
        var self = this;
        return ajaxRequest('createOrder/selectOnlineByType', {
          type: 'order_p_deptid'
        }).then(function (deptList) {
          deptList = _.orderBy(deptList, ['status'], ['desc']);
          dropdownOption.deptList = deptList;
          self.deptList = deptList;
          self.loading = false;
        }).catch(function () {
          self.loading = false;
        });
      }
    },

    template: template
  };
}();
